package com.cc.config;


import org.springframework.context.annotation.*;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;

@Configuration
@ComponentScan(
        //  指定要扫描的包
        basePackages = "com.cc",
        //  指定不扫描的类
        excludeFilters = @ComponentScan.Filter
        (type = FilterType.ANNOTATION,
        classes = {Controller.class, RestController.class})
)
@PropertySource("classpath:database.properties")
@Import({JdbcConfig.class, MyBatisConfig.class})
@EnableAspectJAutoProxy //  开启AOP
@EnableTransactionManagement    //开启事务
public class SpringConfig {


    @Bean
    public DataSourceTransactionManager  transactionManager(DataSource dataSource)
        {
            return new DataSourceTransactionManager(dataSource);
        }
}
